home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 17 / CU Amiga Magazine's Super CD-ROM 17 (1997)(EMAP Images)(GB)[!][issue 1997-12].iso / CUCD / Programming / DiceSource / doc / mungwall.doc < prev    next >
Text File  |  1994-06-10  |  16KB  |  385 lines

  1. Mungwall 37.71 (c) 1988-93 Commodore-Amiga, Inc. All Rights Reserved
  2. Munglist 37.12 (c) 1992-93 Commodore-Amiga, Inc. All Rights Reserved
  3.  
  4. Mungwall munges memory and watches for illegal FreeMem's.
  5. Mungwall is especially useful in combination with Enforcer.
  6. Output is either serial or parallel (mungwall.par), or local by
  7. using both mungwall and a local serial debug capture tool such
  8. as Sushi.
  9.  
  10. Munglist may be used in conjunction with Mungwall, and allows you to
  11. list the owners and allocation information for memory blocks which are
  12. in-use, and perform other memory functions.  See Munglist.doc after
  13. Mungwall.doc.
  14.  
  15.  
  16. Mungwall.doc
  17. ============
  18.  
  19. Revisions
  20. =========
  21.  
  22. (Thanks to Vic Wagner for SAS-6ifying and fixing some bugs!)
  23.  
  24. $Log: mungwall.doc,v $
  25. # Revision 30.0  1994/06/10  17:54:51  dice
  26. # .
  27. #
  28. Revision 37.71  1993/10/02  03:48:13  Vic
  29. Changed - the way the length of the task/process name is calculated.
  30.           There was a slight bug if the name had no 'path' in it and
  31.           was not terminated with a null which could cause problems
  32.           if some arguments had originally been given to the program
  33.  
  34. Revision 37.70  1993/10/01  22:59:35  Vic
  35. Deleted - from this document all the Munglist stuff (it has it's own document
  36.           now.
  37. Added   - RCS Id and Log information for future tracking
  38. Changed - the munging of C0DEF00D to C0DEFEED which was installed in 37.49
  39.           should now work.
  40.         - all other changes had to do with 'moving' to SAS C 6.x
  41.  
  42.  
  43. Since 37.49 MungWall, NAMETAG option tags each allocation with the name
  44. of the allocator.  The new "MUNGLIST" program examines used memory areas
  45. for mungwall tag info, and outputs a list of who owns the various
  46. pieces of allocated memory, their sizes, etc.  If you have used the
  47. NAMETAG option of MungWall, this list will include the name of the
  48. task or command that allocated the memory.  Note that certain
  49. allocations belonging to your program may be displayed as belonging
  50. to another task (such as the task of a disk device that you
  51. locked a file on or accessed).
  52.  
  53. Mungwall 37.51 adds an AvailMem wedge which reduces reported available
  54. memory by the size which Mungwall will add to any allocation.  It also
  55. correct a problem which had caused the NAMETAG option to crash on a
  56. 68000.
  57.  
  58. Mungwall 37.52 fixes Enforcer hits in task name comparisons and adds
  59. better A6 handling when calling the real memory functions.
  60.  
  61. Mungwall 37.53 should finally fix mungwall crashes on 68000 when
  62. using taskname-related options.
  63.  
  64. Mungwall 37.54 - some fixes to output during initialization
  65.  
  66. Mungwall 37.55 - fixes a bug in Mungwall where last chunk of memory
  67.    could be lost, and fixes a similar bug in munglist which could occur
  68.    if munglist's buffer filled.  Also added munglist bufsize argument.
  69.  
  70. Mungwall 37.57 - stops null terminating cli_CommandName in place which
  71.    makes mungwall name options again compatible with DMAKE and ARexx
  72.    scripts with 1-character names.  Adds new SHOWFAIL option which
  73.    tells Mungwall to report all failed allocations.  Changes the output
  74.    text "(at 0xhhhhhhh)" to "(task 0xhhhhhhh)" to be easier to understand.
  75.  
  76. Mungwall 37.58 - adds matching NO and UPDATE options for SHOWSTACK,
  77.    NAMETAG, and SHOWFAIL.
  78.  
  79. Mungwall 37.60 - adds SHOWPC dump of memory at A: and C: caller addresses
  80.    and a matching NOSHOWPC option.  Does not show a supposed PC address
  81.    if it is not RAM according to TypeOfMem().  This is to help prevent
  82.    enforcer hits or worse, possible reads (or read-triggered writes)
  83.    to hardware registers.
  84.  
  85. Mungwall 37.61 and Munglist 37.4 - Add the important capability for
  86.    Mungwall to distinguish between old mungwall cookies left over in
  87.    memory after rebooting, and new ones.  The mungwall info area on
  88.    each allocation has been enlarged by 8 bytes and now contains a
  89.    second per-session cookie which is based on the datestamp
  90.    when mungwall is first started.   Munglist has been enhanced
  91.    to show the addresses applications received when they allocated
  92.    memory, not the address of the larger piece mungwall allocated.
  93.    Some changes to output format.
  94.  
  95. Mungwall 37.62 implements a new default rolling fill character for
  96.    the walls surrounding memory allocations.  Each allocation gets
  97.    a new fill character between $81 and $FF.  This allows Mungwall to
  98.    generally catch errors where too much memory has been copied
  99.    from one allocation to another.  Note that the explicit FILLCHAR
  100.    option of Mungwall now disables the rolling fillchar feature.
  101.    Do not use the FILLCHAR option if you want the protection of the
  102.    rolling fill char.  Some changes to output format.
  103.  
  104. Mungwall 37.63 adds SHOWHUNK and NOSHOWHUNK options.  With SHOWHUNK,
  105.    mungwall will attempt to show the hunk and offset for the probable
  106.    C or Asm PC addresses of the caller generating the hit if the PC
  107.    address is in RAM and also within the seglist of the caller's process.
  108.  
  109. Mungwall 37.64 adds SegTracker support.  If SHOWHUNK is option is on,
  110.    if SegTracker is installed, mungwall will get hunk/offset info
  111.    from SegTracker, else mungwall can only check if the probable
  112.    PC addresses are in the calling process's own SegList.
  113.  
  114. Mungwall 37.65 - Fixes output where decimal size was being printed
  115.    as if it were a hex number 0xnnnn  (should be just nnnn)
  116.  
  117. Mungwall 37.67 - Adds TIMESTAMP option
  118.  
  119. Mungwall 37.68 - Adds timestamp output to hits and snoops if TIMESTAMP on
  120.  
  121. Mungwall 37.69 - Modified for new Munglist MARK option
  122.  
  123.  
  124. What Mungwall Does
  125. ==================
  126.  
  127. Memory munging:
  128.  
  129.  - Except when Enforcer is running, location 0 is set to $C0DEDBAD, i.e.
  130.    programs referencing location zero will not f.e. find a null string.
  131.  
  132.  - On startup all free memory is munged with $ABADCAFE. If this number
  133.    shows up, someone is referencing memory in the free list.
  134.  
  135.  - Except when MEMF_CLEAR is set, memory is pre-munged on allocation with
  136.    $DEADFOOD. When this is used in an Enforcer report, the caller is
  137.    allocating memory and doesn't initialize it before using it. Note that
  138.    only memory which has a cookie attached will be pre-munged.
  139.  
  140.  - Memory is filled with $DEADBEEF before it is freed, encouraging
  141.    programs reusing free'ed memory to crash.
  142.  
  143. Memory watching:
  144.  
  145. Mungwall places a magic cookie before the memory allocation.
  146. Along with a wall of bytes on either side of the allocation to keep an
  147. eye on the memory just before or after the allocation. If the
  148. memory wall is trashed, mungwall complains and shows the damaged area.
  149. If memory is trashed so bad that the cookie is completely gone, Mungwall
  150. will not consider it a walled memory allocation and lets it go. Changes
  151. are you'll be corrupting the memory list and/or overwriting other memory
  152. allocation and crash soon after that. If a mungwall hit occurs, memory
  153. will not be munged or free'ed, to give you a change to look at what was
  154. written there.
  155.  
  156. Both null pointer FreeMem()'s and null sized Alloc/FreeMem()'s trigger
  157. mungwall. Mungwall also gets upset when a memoryblock is free'ed with a
  158. size different from the one used for allocating the memoryblock, and will
  159. say so. The integrity of the walls will be tested according to the size
  160. specified on allocation time, but will not be free'ed.
  161.  
  162. Pointers passed to FreeMem() will be rejected if they are non-longword
  163. alligned. Thus possible catching bogus pointers otherwise left untouched
  164. by mungwall.
  165.  
  166. Unless a specific task(s) is watched and that task leaves before mungwall
  167. does, mungwall will always lose some memory.
  168.  
  169. NOTES:
  170.  
  171. Other debugging tools which SetFunction() AllocMem() and/or
  172. FreeMem() and JSR to what they think is the old memory routine,
  173. should be run BEFORE mungwall. Mungwall needs to know the returnaddress
  174. of the initial caller. Running other debugging tools after mungwall
  175. will result in false reports about layers.library and invalid
  176. mungwall reports about the caller. The 'scratcher' for example must
  177. be run before mungwall, 'memoration' can be run afterwards, since it
  178. JMP's.
  179.  
  180. When mungwall is being stopped, the walls around the original allocations
  181. which are not free'ed at that point, will never get free'ed, only the block
  182. within. Thus causing memory fragmentation and memory loss.
  183. In addition, stopping and restarting mungwall can cause numerous
  184. bogus mungwall hits if applications allocate uncleared memory
  185. (containing unlceared mungwall cookies) while mungwall is off and then
  186. free it when mungwall is back on.
  187.  
  188.  
  189. Memory allocations larger than 3 gigabytes will not be marked by mungwall.
  190.  
  191. Usage: Mungwall [UPDATE] [TASK name] [(NO)WAIT] [(NO)SHOWFAIL]
  192.   [(NO)SNOOP] [INFO] [(NO)SHOWSTACK] [(NO)SHOWPC] [(NO)SHOWHUNK]
  193.   [(NO)NAMETAG] [(NO)TIMESTAMP] [PRESIZE n] [POSTSIZE n] [FILLCHAR 0xHH]
  194.  
  195. TASK name   - Watch only the task(s), or all but the task(s) specified
  196.               with 'name'. Multiple tasknames are indicated by placing
  197.               a '|' between the names. If the names are preceeded by an
  198.               exclamation mark, all tasks except the ones indicated are
  199.               tracked. ALL is a reserved name, indicating all tasks
  200.               should be tracked. Default ALL.
  201.  
  202. PRESIZE     - Size of wall before memory allocation in bytes. Minimum 4,
  203.               maximum 64. Default 32.
  204.  
  205. POSTSIZE    - Size of wall after memory allocation in bytes. Minimum 4,
  206.               maximum 64. The actual number of bytes after the allocation
  207.               may vary slightly, since it's upped to the nearest longword.
  208.               Default 32.
  209.  
  210. FILLCHAR n  - Character to build the memory wall with. Can be indicated
  211.               both hexadecimal and decimal. Default is a rolling fillchar
  212.           which uses a new odd number between $81 and $FF for each
  213.           new allocation.  This makes it possible for Mungwall to
  214.           usually catch errors where too much memory is copied
  215.           from one allocation to another.  Specifying a FILLCHAR
  216.           disables the default rolling fillchar feature.
  217.           
  218. SNOOP       - Produce snoop compatible output. No snoop output is given
  219.               for illegal FreeMem's. Default OFF. Layers AllocMem's and
  220.               FreeMem's are never snooped. SNOOP is particulary useful
  221.               in combination with TASK. Snoop output can be filtered
  222.               with 'snoopstrip' to find the origin of memory loss.
  223.  
  224. WAIT        - Halt task causing a hit and wait for Ctrl-C. Make sure you
  225.             - can issue a break to the task. WAIT can be used without
  226.               specifying a specific taskname to watch. Default OFF.
  227.  
  228. INFO        - Show configuration information.
  229.  
  230. SHOWSTACK   - Show 32 longwords of the stack whenever a hit/snoop occurs
  231.  
  232. NAMETAG     - Tag each allocation with allocating task or command's name
  233.  
  234. SHOWFAIL    - Tells mungwall to report all memory allocation failures
  235.  
  236. SHOWPC        - Show a dump of memory at the A: and C: possible PC
  237.           (program counter) addresses (one should be correct)
  238.               Does not show a supposed PC address if it is not RAM
  239.               according to TypeOfMem().  This is to help prevent enforcer
  240.               hits or worse, possible reads (or read-triggered writes)
  241.               to hardware registers.
  242.  
  243. SHOWHUNK    - On a hit or snoop, if the probable PC address of a reported
  244.           call to AllocMem or FreeMem is within the calling process's
  245.           seglist, attempt to show hunk and offset information.
  246.  
  247. TIMESTAMP   - Timestamp each allocation with system time
  248.  
  249. UPDATE      - Indicates an already running mungwall task should be up-
  250.               dated with new parameters. Presize, postsize and fillchar
  251.               can never be updated.  NOTE - when doing an UPDATE, the
  252.           UPDATE option must be the first command line arg
  253.  
  254. The following are extra updating parameters.
  255.  
  256. NOSNOOP     - Turn snooping off.
  257.  
  258. NOWAIT      - No longer halt a task in case of an error.
  259.  
  260. NONAMETAG   - Turn off taskname storage
  261.  
  262. NOSHOWSTACK - Turn off showstack option
  263.  
  264. NOSHOWFAIL  - Turn off option that displays memory allocation failures
  265.  
  266. NOSHOWPC    - Turn off option that displays dump of memory at caller PC
  267.  
  268. NOSHOWHUNK  - Turn off options that displays hunk and offset information
  269.  
  270. NOTIMESTAMP - Turn off the timestamping feature
  271.  
  272.  
  273.  
  274.  
  275. Munglist.doc
  276. ============
  277.  
  278. Munglist examines memory for in-use pieces of memory which were allocated
  279. while mungwall was active.  Mungwall saves special information at the start
  280. of each allocation.  Munglist finds this information and outputs it,
  281. providing a fairly accurate list of currently-in-use pieces of memory
  282. and who allocated them.
  283.  
  284. Revisions
  285. =========
  286.  
  287. $Log: mungwall.doc,v $
  288. # Revision 30.0  1994/06/10  17:54:51  dice
  289. # .
  290. #
  291. ; Revision 37.12  1993/10/01  23:09:52  Vic
  292. ; Added   - ONLY option
  293. ;         - MARK/SINCE MARK description to the 'usage'
  294. ;         - RCS Id and Log information for future tracking
  295. ; Changed - only slightly the ordering of this document (put what Munglist
  296. ;           is as the 1st paragraph)
  297. ;         - separated this document from the combined document with Mungwall
  298. ;
  299.  
  300. MungList 37.6 adds serial-output memory checking and remunging options
  301.  
  302. Munglist 37.8 adds SHOWTIME option (displays TIMESTAMP above)
  303.  
  304. Munglist 37.10 adds MARK and SINCE MARK options
  305.  
  306. Munglist 37.11 removes debugging line, adds TOTAL taskname option
  307.  
  308.  
  309.  
  310. Usage: munglist [buffsize] [SHOWHUNK] [CHECK] [REMUNGE] [SHOWTIME] [-tickdelay]
  311.                 [MARK] [SINCE MARK] [ONLY|TOTAL taskname]
  312. Requires mungwall 37.69+.  SHOWTIME requires V37+ and mungwall 37.69+.
  313. Output errors possible for memory freed and/or reallocated while listing
  314. Good SHOWHUNK output requires SegTracker and still-loaded allocating program
  315. CHECK/REMUNGE are serial output and turn off listing. tickdelay is for CHECK
  316. MARK saves the current time for use with:
  317. SINCE MARK lists only allocations which have occured SINCE the MARKed time
  318. ONLY Taskname list ONLY allocations by that task (implies TOTAL also)
  319. TOTAL Taskname just totals up the amount currently allocated by that task
  320. Default buffsize is 8000
  321.  
  322.  
  323. buffsize option
  324.  
  325. The default 8000 byte buffer used by munglist may not be large enough to
  326. capture a large or fragmented memory list.  To provide a different
  327. buffsize, just pass the size in bytes as the first argument.
  328.  
  329. SHOWHUNK option
  330.  
  331. With the SHOWHUNK option (and SegTracker from The Enforcer archive running),
  332. Munglist will try to show possible Hunk and Offset from which memory was
  333. allocated.  This can be inexact since one program may have forgotten to
  334. free memory, and another program may now be loaded in the same location
  335. the old program was unloaded from.
  336.  
  337. SHOWTIME option
  338.  
  339. If TIMESTAMP was specifed for Mungwall, the SHOWTIME option of Munglist
  340. can show you the time each allocation was made.
  341.  
  342. MARK option
  343.  
  344. Tells MungList to mark the current time, for use by SINCE MARK.
  345. If this is the only argument passed, munglist will mark and exit.
  346. Mark (m) is now also offered as an option when munglist presents
  347. its interactive prompt after listing.
  348.  
  349. SINCE MARK option
  350.  
  351. Tells MungList to only list allocations made since the MARK time.
  352. When done, the new prompt will offer choices to quit, mark again,
  353. run again.  This allows you to just list recent allocations.
  354. SINCE MARK may be used in combination with the MARK option to avoid
  355. an overly long first list.
  356.  
  357. TOTAL taskname
  358.  
  359. This tells munglist to just total up the amount of memory allocated
  360. by the named task.  This can be used with the SINCE MARK option.
  361.  
  362.  
  363. NOTE: The REMUNGE and CHECK options TURN OFF the stdout munglist output
  364.  
  365.  
  366. REMUNGE option
  367.  
  368. Instead of outputting a list of memory chunks in use, MungList will
  369. remunge free memory, outputting a short serial message.
  370.  
  371.  
  372. CHECK option
  373.  
  374. Instead of outputting a list of memory pieces in use, MungList will
  375. check the in-use memory pieces for trashed bytes before or after
  376. each allocation.  A short serial message is output, followed by
  377. mungwall-like serial error output for any trashed memory pieces.
  378.  
  379. -tickdelay
  380.  
  381. Tells MungList CHECK or REMUNGE to stay loaded and loop every tickdelay
  382. 50th's of a second.
  383.  
  384.  
  385.